package android.demo.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.demo.Constants.Action;
import android.demo.Constants.Extra;
import android.util.Log;
import android.widget.Toast;

public class TestBroadcastReceiver extends BroadcastReceiver {

	private final String TAG = TestBroadcastReceiver.class.getSimpleName();

	public TestBroadcastReceiver() {
		Log.i(TAG, "---------------------------------------------------------------------------------------");
		Log.i(TAG, this + " ................onCreate");
	}
	
	public void onReceive(Context context, Intent intent) {
		if (intent.getAction().equals(Action.BROADCAST_TEST_RECEIVER)) {
			String msg = intent.getStringExtra(Extra.BROADCAST_MSG);
			Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
		} else if (intent.getAction().equals(Action.BROADCAST_DISPLAY_RECEIVER)) {
			Intent i = new Intent();
			i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			i.setClass(context, DisplayActivity.class);
			context.startActivity(i);
		}
	}

}
